﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class uc_Login : System.Web.UI.UserControl
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}

	protected void submit(object sender, EventArgs e)
	{
		string id = Request.Form.Get("txtId");
		string pw = Request.Form.Get("txtPassword");
	
		string hostname = null;
		string ipaddr = null;
		System.Net.IPAddress[] ips;
		hostname = System.Net.Dns.GetHostName();
		ips = System.Net.Dns.GetHostAddresses(hostname);
		foreach (System.Net.IPAddress ip in ips)
		{
			ipaddr = ip.ToString();
		}
		
		TimeCapsule.Member mb = TimeCapsule.Member.Login(id.Trim(), pw.Trim());
		if( !string.IsNullOrEmpty(mb.key) )
		{
			if( !TimeCapsule.Util.decryptKey(mb.key) )
			{
				mb.Email = "";
				mb.Role = 0;
				mb.key = "";
			}
		}
		if (mb.key == "")
		{
			Response.Redirect("login.aspx");
			Response.Write("로그인실패");
		}
		Response.Redirect(Request.Url.ToString());
	}
}